package FSMDemo.entity.Harvester
{
	
	import FSMDemo.entity.mine.Mine;
	
	import com.cheezeworld.AI.FSM.StateMachine;
	import com.cheezeworld.entity.Boid;

	public class Harvester extends Boid
	{
		
		public var FSM:StateMachine;
		public var status:String;
		public var goldOnHand:Number;
		public var harvestPerSecond:Number;
		public var capacity:Number;
		
		public function Harvester(a_params:HarvesterParams)
		{
			super(a_params);
			
			FSM = new StateMachine( this );
			capacity = a_params.capacity;
			harvestPerSecond = a_params.harvestPerSecond;
			goldOnHand = 0;
			status = "Not doing anything";
		}
		
		public override function update(a_timePassed:int):void
		{
			setInitialValues( a_timePassed );
			
			calculateForces()	 
			
			calculateSteering(); 
			
			FSM.update();
 			
 			calculateFinalVelocity();
 			
 			updateHeading();

 			updatePosition();
 			
 			updateChildren( a_timePassed );
		}
		
		public function harvest( a_mine:Mine ) : void
		{
			goldOnHand += a_mine.harvest( _stepSize * harvestPerSecond )
			if( goldOnHand >= capacity )
			{
				goldOnHand = capacity;
			}
		}
		
	}
}